home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / CDLOGMenuBar / utilities.cp < prev    next >
Text File  |  1996-04-02  |  3KB  |  87 lines

  1. /************************************************************************
  2. *****    File : Utilities.cp                                            *****
  3. *****    Copyright 1996, Thomas R. Kimpton                            *****
  4. *****        All Rights Reserved                                        *****
  5. *****                                                                *****
  6. *****    This source code may be freely used in any programming        *****
  7. *****    project so long as credit is duly noted of the author.        *****
  8. ************************************************************************/
  9. #include    "Utilities.h"
  10.  
  11. //• --------------------------------------------------------------- •//
  12. void ShadowBox (Rect someRect)                //• Receive rect to be done.
  13. {
  14. short width = (someRect.right - someRect.left) + 2;  // Because we inset it below...
  15. short height = (someRect.bottom - someRect.top) + 2;  // Because we inset it below...
  16.  
  17.     EraseRect (&someRect);                //• Clean out the in'ards.
  18.     InsetRect (&someRect, -1, -1);        //• Expand it by 1, all sides.
  19.     SetForeColor (0, 0, 0);                //• black...
  20.     FrameRect (&someRect);                //• ...frame it.
  21.     SetForeColor (0x4444, 0x4444, 0x4444);    //• Using  2/3 gray...
  22.     MoveTo(someRect.left,someRect.bottom);
  23.     Line(width,0);
  24.     Line(0,-height);
  25.     SetForeColor (0x8888, 0x8888, 0x8888);    //• Using  1/3 gray...
  26.     MoveTo(someRect.left+1,someRect.bottom+1);
  27.     Line(width,0);
  28.     Line(0,-height);
  29. }
  30.  
  31. void SetForeColor(short red, short green, short blue)
  32. {
  33.     RGBColor hue;
  34.  
  35.     hue.red = red;
  36.     hue.green = green;
  37.     hue.blue = blue;
  38.  
  39.     RGBForeColor (&hue);
  40. }
  41.  
  42. //• --------------------------------------------------------------- •//
  43. void SetBackColor(short red, short green, short blue)
  44. {
  45.     RGBColor hue;
  46.  
  47.     hue.red = red;
  48.     hue.green = green;
  49.     hue.blue = blue;
  50.  
  51.     RGBBackColor (&hue);
  52. }
  53.  
  54. /************************************************************************
  55. *****    Get the state of the handle, lock it and return the state.    *****
  56. ************************************************************************/
  57. char
  58. HLockState(Handle theHndl)
  59. {
  60. char oldState;
  61.  
  62.     oldState = HGetState(theHndl);
  63.     HLock(theHndl);
  64.     return(oldState);
  65. } /* HLockState() */
  66.  
  67. /************************************************************************
  68. *****    thisLoc is a point in some device's screen rect, iterate    *****
  69. *****    through the screen device list and find and return the        *****
  70. *****    portRect.  If thisLoc isn't on any screen, return false.    *****
  71. ************************************************************************/
  72. Boolean
  73. GetPortRectForThisPoint(Point thisLoc,Rect *thePortRect)
  74. {
  75. GDHandle    gdNthDevice;
  76.  
  77.     gdNthDevice = GetDeviceList();
  78.     while(gdNthDevice){
  79.         if(PtInRect(thisLoc,&(**gdNthDevice).gdRect)){
  80.             *thePortRect = (**gdNthDevice).gdRect;
  81.             return(true);
  82.         }
  83.         gdNthDevice = GetNextDevice(gdNthDevice);
  84.     }
  85.     return(false);
  86. }
  87.